import { defineComponent, ref, computed, resolveComponent, openBlock, createBlock, mergeProps, unref, useCssVars, watch, createElementBlock, createVNode, createSlots, withCtx, createCommentVNode, createElementVNode, createTextVNode } from "vue";
import { cloneDeep } from "lodash-es";
import { PlusOutlined } from "@ant-design/icons-vue";
import { message, Upload as Upload$1 } from "ant-design-vue";
/*!
 * is-plain-object <https://github.com/jonschlinkert/is-plain-object>
 *
 * Copyright (c) 2014-2017, Jon Schlinkert.
 * Released under the MIT License.
 */
function isObject(o2) {
  return Object.prototype.toString.call(o2) === "[object Object]";
}
function isPlainObject(o2) {
  var ctor, prot;
  if (isObject(o2) === false)
    return false;
  ctor = o2.constructor;
  if (ctor === void 0)
    return true;
  prot = ctor.prototype;
  if (isObject(prot) === false)
    return false;
  if (prot.hasOwnProperty("isPrototypeOf") === false) {
    return false;
  }
  return true;
}
function t() {
  return t = Object.assign || function(e) {
    for (var t2 = 1; t2 < arguments.length; t2++) {
      var r2 = arguments[t2];
      for (var n2 in r2)
        Object.prototype.hasOwnProperty.call(r2, n2) && (e[n2] = r2[n2]);
    }
    return e;
  }, t.apply(this, arguments);
}
function r(e, t2) {
  if (e == null)
    return {};
  var r2, n2, i2 = {}, o2 = Object.keys(e);
  for (n2 = 0; n2 < o2.length; n2++)
    t2.indexOf(r2 = o2[n2]) >= 0 || (i2[r2] = e[r2]);
  return i2;
}
const n = { silent: false, logLevel: "warn" }, i = ["validator"], o = Object.prototype, a = o.toString, s = o.hasOwnProperty, u = /^\s*function (\w+)/;
function l(e) {
  var t2;
  const r2 = (t2 = e == null ? void 0 : e.type) !== null && t2 !== void 0 ? t2 : e;
  if (r2) {
    const e2 = r2.toString().match(u);
    return e2 ? e2[1] : "";
  }
  return "";
}
const c = isPlainObject, f = (e) => e;
let d = f;
const p = (e, t2) => s.call(e, t2), y = Number.isInteger || function(e) {
  return typeof e == "number" && isFinite(e) && Math.floor(e) === e;
}, v = Array.isArray || function(e) {
  return a.call(e) === "[object Array]";
}, h = (e) => a.call(e) === "[object Function]", b = (e) => c(e) && p(e, "_vueTypes_name"), g = (e) => c(e) && (p(e, "type") || ["_vueTypes_name", "validator", "default", "required"].some((t2) => p(e, t2)));
function O(e, t2) {
  return Object.defineProperty(e.bind(t2), "__original", { value: e });
}
function m(e, t2, r2 = false) {
  let n2, i2 = true, o2 = "";
  n2 = c(e) ? e : { type: e };
  const a2 = b(n2) ? n2._vueTypes_name + " - " : "";
  if (g(n2) && n2.type !== null) {
    if (n2.type === void 0 || n2.type === true)
      return i2;
    if (!n2.required && t2 === void 0)
      return i2;
    v(n2.type) ? (i2 = n2.type.some((e2) => m(e2, t2, true) === true), o2 = n2.type.map((e2) => l(e2)).join(" or ")) : (o2 = l(n2), i2 = o2 === "Array" ? v(t2) : o2 === "Object" ? c(t2) : o2 === "String" || o2 === "Number" || o2 === "Boolean" || o2 === "Function" ? function(e2) {
      if (e2 == null)
        return "";
      const t3 = e2.constructor.toString().match(u);
      return t3 ? t3[1] : "";
    }(t2) === o2 : t2 instanceof n2.type);
  }
  if (!i2) {
    const e2 = `${a2}value "${t2}" should be of type "${o2}"`;
    return r2 === false ? (d(e2), false) : e2;
  }
  if (p(n2, "validator") && h(n2.validator)) {
    const e2 = d, o3 = [];
    if (d = (e3) => {
      o3.push(e3);
    }, i2 = n2.validator(t2), d = e2, !i2) {
      const e3 = (o3.length > 1 ? "* " : "") + o3.join("\n* ");
      return o3.length = 0, r2 === false ? (d(e3), i2) : e3;
    }
  }
  return i2;
}
function j(e, t2) {
  const r2 = Object.defineProperties(t2, { _vueTypes_name: { value: e, writable: true }, isRequired: { get() {
    return this.required = true, this;
  } }, def: { value(e2) {
    return e2 === void 0 ? (p(this, "default") && delete this.default, this) : h(e2) || m(this, e2, true) === true ? (this.default = v(e2) ? () => [...e2] : c(e2) ? () => Object.assign({}, e2) : e2, this) : (d(`${this._vueTypes_name} - invalid default value: "${e2}"`), this);
  } } }), { validator: n2 } = r2;
  return h(n2) && (r2.validator = O(n2, r2)), r2;
}
function _(e, t2) {
  const r2 = j(e, t2);
  return Object.defineProperty(r2, "validate", { value(e2) {
    return h(this.validator) && d(`${this._vueTypes_name} - calling .validate() will overwrite the current custom validator function. Validator info:
${JSON.stringify(this)}`), this.validator = O(e2, this), this;
  } });
}
function T(e, t2, n2) {
  const o2 = function(e2) {
    const t3 = {};
    return Object.getOwnPropertyNames(e2).forEach((r2) => {
      t3[r2] = Object.getOwnPropertyDescriptor(e2, r2);
    }), Object.defineProperties({}, t3);
  }(t2);
  if (o2._vueTypes_name = e, !c(n2))
    return o2;
  const { validator: a2 } = n2, s2 = r(n2, i);
  if (h(a2)) {
    let { validator: e2 } = o2;
    e2 && (e2 = (l2 = (u2 = e2).__original) !== null && l2 !== void 0 ? l2 : u2), o2.validator = O(e2 ? function(t3) {
      return e2.call(this, t3) && a2.call(this, t3);
    } : a2, o2);
  }
  var u2, l2;
  return Object.assign(o2, s2);
}
function $(e) {
  return e.replace(/^(?!\s*$)/gm, "  ");
}
const w = () => _("any", {}), P = () => _("function", { type: Function }), x = () => _("boolean", { type: Boolean }), E = () => _("string", { type: String }), N = () => _("number", { type: Number }), q = () => _("array", { type: Array }), A = () => _("object", { type: Object }), V = () => j("integer", { type: Number, validator: (e) => y(e) }), S = () => j("symbol", { validator: (e) => typeof e == "symbol" });
function k(e, t2 = "custom validation failed") {
  if (typeof e != "function")
    throw new TypeError("[VueTypes error]: You must provide a function as argument");
  return j(e.name || "<<anonymous function>>", { type: null, validator(r2) {
    const n2 = e(r2);
    return n2 || d(`${this._vueTypes_name} - ${t2}`), n2;
  } });
}
function D(e) {
  if (!v(e))
    throw new TypeError("[VueTypes error]: You must provide an array as argument.");
  const t2 = `oneOf - value should be one of "${e.join('", "')}".`, r2 = e.reduce((e2, t3) => {
    if (t3 != null) {
      const r3 = t3.constructor;
      e2.indexOf(r3) === -1 && e2.push(r3);
    }
    return e2;
  }, []);
  return j("oneOf", { type: r2.length > 0 ? r2 : void 0, validator(r3) {
    const n2 = e.indexOf(r3) !== -1;
    return n2 || d(t2), n2;
  } });
}
function L(e) {
  if (!v(e))
    throw new TypeError("[VueTypes error]: You must provide an array as argument");
  let t2 = false, r2 = [];
  for (let n3 = 0; n3 < e.length; n3 += 1) {
    const i2 = e[n3];
    if (g(i2)) {
      if (b(i2) && i2._vueTypes_name === "oneOf" && i2.type) {
        r2 = r2.concat(i2.type);
        continue;
      }
      if (h(i2.validator) && (t2 = true), i2.type === true || !i2.type) {
        d('oneOfType - invalid usage of "true" or "null" as types.');
        continue;
      }
      r2 = r2.concat(i2.type);
    } else
      r2.push(i2);
  }
  r2 = r2.filter((e2, t3) => r2.indexOf(e2) === t3);
  const n2 = r2.length > 0 ? r2 : null;
  return j("oneOfType", t2 ? { type: n2, validator(t3) {
    const r3 = [], n3 = e.some((e2) => {
      const n4 = m(b(e2) && e2._vueTypes_name === "oneOf" ? e2.type || null : e2, t3, true);
      return typeof n4 == "string" && r3.push(n4), n4 === true;
    });
    return n3 || d(`oneOfType - provided value does not match any of the ${r3.length} passed-in validators:
${$(r3.join("\n"))}`), n3;
  } } : { type: n2 });
}
function F(e) {
  return j("arrayOf", { type: Array, validator(t2) {
    let r2 = "";
    const n2 = t2.every((t3) => (r2 = m(e, t3, true), r2 === true));
    return n2 || d(`arrayOf - value validation error:
${$(r2)}`), n2;
  } });
}
function Y(e) {
  return j("instanceOf", { type: e });
}
function B(e) {
  return j("objectOf", { type: Object, validator(t2) {
    let r2 = "";
    const n2 = Object.keys(t2).every((n3) => (r2 = m(e, t2[n3], true), r2 === true));
    return n2 || d(`objectOf - value validation error:
${$(r2)}`), n2;
  } });
}
function I(e) {
  const t2 = Object.keys(e), r2 = t2.filter((t3) => {
    var r3;
    return !((r3 = e[t3]) === null || r3 === void 0 || !r3.required);
  }), n2 = j("shape", { type: Object, validator(n3) {
    if (!c(n3))
      return false;
    const i2 = Object.keys(n3);
    if (r2.length > 0 && r2.some((e2) => i2.indexOf(e2) === -1)) {
      const e2 = r2.filter((e3) => i2.indexOf(e3) === -1);
      return d(e2.length === 1 ? `shape - required property "${e2[0]}" is not defined.` : `shape - required properties "${e2.join('", "')}" are not defined.`), false;
    }
    return i2.every((r3) => {
      if (t2.indexOf(r3) === -1)
        return this._vueTypes_isLoose === true || (d(`shape - shape definition does not include a "${r3}" property. Allowed keys: "${t2.join('", "')}".`), false);
      const i3 = m(e[r3], n3[r3], true);
      return typeof i3 == "string" && d(`shape - "${r3}" property validation error:
 ${$(i3)}`), i3 === true;
    });
  } });
  return Object.defineProperty(n2, "_vueTypes_isLoose", { writable: true, value: false }), Object.defineProperty(n2, "loose", { get() {
    return this._vueTypes_isLoose = true, this;
  } }), n2;
}
const J = ["name", "validate", "getter"], M = /* @__PURE__ */ (() => {
  var e, t2;
  return t2 = e = class {
    static get any() {
      return w();
    }
    static get func() {
      return P().def(this.defaults.func);
    }
    static get bool() {
      return x().def(this.defaults.bool);
    }
    static get string() {
      return E().def(this.defaults.string);
    }
    static get number() {
      return N().def(this.defaults.number);
    }
    static get array() {
      return q().def(this.defaults.array);
    }
    static get object() {
      return A().def(this.defaults.object);
    }
    static get integer() {
      return V().def(this.defaults.integer);
    }
    static get symbol() {
      return S();
    }
    static extend(e2) {
      if (v(e2))
        return e2.forEach((e3) => this.extend(e3)), this;
      const { name: t3, validate: n2 = false, getter: i2 = false } = e2, o2 = r(e2, J);
      if (p(this, t3))
        throw new TypeError(`[VueTypes error]: Type "${t3}" already defined`);
      const { type: a2 } = o2;
      if (b(a2))
        return delete o2.type, Object.defineProperty(this, t3, i2 ? { get: () => T(t3, a2, o2) } : { value(...e3) {
          const r2 = T(t3, a2, o2);
          return r2.validator && (r2.validator = r2.validator.bind(r2, ...e3)), r2;
        } });
      let s2;
      return s2 = i2 ? { get() {
        const e3 = Object.assign({}, o2);
        return n2 ? _(t3, e3) : j(t3, e3);
      }, enumerable: true } : { value(...e3) {
        const r2 = Object.assign({}, o2);
        let i3;
        return i3 = n2 ? _(t3, r2) : j(t3, r2), r2.validator && (i3.validator = r2.validator.bind(i3, ...e3)), i3;
      }, enumerable: true }, Object.defineProperty(this, t3, s2);
    }
  }, e.defaults = {}, e.sensibleDefaults = void 0, e.config = n, e.custom = k, e.oneOf = D, e.instanceOf = Y, e.oneOfType = L, e.arrayOf = F, e.objectOf = B, e.shape = I, e.utils = { validate: (e2, t3) => m(t3, e2, true) === true, toType: (e2, t3, r2 = false) => r2 ? _(e2, t3) : j(e2, t3) }, t2;
})();
function R(e = { func: () => {
}, bool: true, string: "", number: 0, array: () => [], object: () => ({}), integer: 0 }) {
  var r2, n2;
  return n2 = r2 = class extends M {
    static get sensibleDefaults() {
      return t({}, this.defaults);
    }
    static set sensibleDefaults(r3) {
      this.defaults = r3 !== false ? t({}, r3 !== true ? r3 : e) : {};
    }
  }, r2.defaults = t({}, e), n2;
}
class z extends R() {
}
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
  __name: "index",
  props: {
    action: z.string.isRequired,
    headers: z.object.def({}),
    formatResponse: P().def((res) => res.data),
    multiple: z.bool.def(false),
    disabled: z.bool.def(false),
    allowClear: z.bool.def(false),
    placeholder: z.string.def("\u8BF7\u9009\u62E9"),
    range: z.oneOf(["country", "province", "city"]).def("country"),
    parentName: z.string.def(""),
    singleLevel: z.bool.def(false),
    value: z.arrayOf(z.oneOfType([String, Number])).def([])
  },
  emits: ["update:value", "change"],
  setup(__props, { emit: emits }) {
    const props = __props;
    const originData = ref([]);
    const loading = ref(true);
    function getAreaList() {
      const historyData = JSON.parse(sessionStorage.getItem("area-select-component") || "[]");
      if (historyData && historyData.length) {
        originData.value = historyData;
        loading.value = false;
      } else {
        fetch(props.action, { headers: props.headers }).then((fetchRes) => {
          fetchRes.json().then((res) => {
            const formatData = props.formatResponse(res);
            originData.value = formatData;
            sessionStorage.setItem("area-select-component", JSON.stringify(formatData));
            loading.value = false;
          });
        });
      }
    }
    getAreaList();
    const localData = computed(() => {
      return cloneDeep(originData.value);
    });
    const areaData = computed(() => {
      if (props.range === "province") {
        const provinceData = localData.value.find((item) => item.label === props.parentName);
        return props.parentName && provinceData ? provinceData.children : localData.value;
      } else if (props.range === "city") {
        if (props.parentName) {
          let localCityData = null;
          for (let i2 = 0; i2 < localData.value.length; i2++) {
            const provinceData = localData.value[i2];
            for (let j2 = 0; j2 < provinceData.children.length; j2++) {
              const cityData = provinceData.children[j2];
              if (cityData.label === props.parentName) {
                localCityData = cityData;
                break;
              }
            }
          }
          return localCityData ? localCityData.children : localData.value;
        } else {
          return localData.value;
        }
      } else {
        return localData.value;
      }
    });
    function singleLevelData(data) {
      return props.singleLevel ? data.map((item) => ({ ...item, children: [] })) : data;
    }
    function handleChange(e) {
      emits("update:value", e);
      emits("change", e);
    }
    return (_ctx, _cache) => {
      const _component_a_cascader = resolveComponent("a-cascader");
      return openBlock(), createBlock(_component_a_cascader, mergeProps(_ctx.$attrs, {
        value: __props.value,
        options: singleLevelData(unref(areaData)),
        placeholder: __props.placeholder,
        disabled: __props.disabled,
        multiple: __props.multiple,
        "allow-clear": __props.allowClear,
        onChange: handleChange,
        loading: loading.value
      }), null, 16, ["value", "options", "placeholder", "disabled", "multiple", "allow-clear", "loading"]);
    };
  }
});
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
var FileSaver_min = { exports: {} };
(function(module, exports) {
  (function(a2, b2) {
    b2();
  })(commonjsGlobal, function() {
    function b2(a3, b3) {
      return typeof b3 == "undefined" ? b3 = { autoBom: false } : typeof b3 != "object" && (console.warn("Deprecated: Expected third argument to be a object"), b3 = { autoBom: !b3 }), b3.autoBom && /^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(a3.type) ? new Blob(["\uFEFF", a3], { type: a3.type }) : a3;
    }
    function c2(a3, b3, c3) {
      var d3 = new XMLHttpRequest();
      d3.open("GET", a3), d3.responseType = "blob", d3.onload = function() {
        g2(d3.response, b3, c3);
      }, d3.onerror = function() {
        console.error("could not download file");
      }, d3.send();
    }
    function d2(a3) {
      var b3 = new XMLHttpRequest();
      b3.open("HEAD", a3, false);
      try {
        b3.send();
      } catch (a4) {
      }
      return 200 <= b3.status && 299 >= b3.status;
    }
    function e(a3) {
      try {
        a3.dispatchEvent(new MouseEvent("click"));
      } catch (c3) {
        var b3 = document.createEvent("MouseEvents");
        b3.initMouseEvent("click", true, true, window, 0, 0, 0, 80, 20, false, false, false, false, 0, null), a3.dispatchEvent(b3);
      }
    }
    var f2 = typeof window == "object" && window.window === window ? window : typeof self == "object" && self.self === self ? self : typeof commonjsGlobal == "object" && commonjsGlobal.global === commonjsGlobal ? commonjsGlobal : void 0, a2 = f2.navigator && /Macintosh/.test(navigator.userAgent) && /AppleWebKit/.test(navigator.userAgent) && !/Safari/.test(navigator.userAgent), g2 = f2.saveAs || (typeof window != "object" || window !== f2 ? function() {
    } : "download" in HTMLAnchorElement.prototype && !a2 ? function(b3, g3, h2) {
      var i2 = f2.URL || f2.webkitURL, j2 = document.createElement("a");
      g3 = g3 || b3.name || "download", j2.download = g3, j2.rel = "noopener", typeof b3 == "string" ? (j2.href = b3, j2.origin === location.origin ? e(j2) : d2(j2.href) ? c2(b3, g3, h2) : e(j2, j2.target = "_blank")) : (j2.href = i2.createObjectURL(b3), setTimeout(function() {
        i2.revokeObjectURL(j2.href);
      }, 4e4), setTimeout(function() {
        e(j2);
      }, 0));
    } : "msSaveOrOpenBlob" in navigator ? function(f3, g3, h2) {
      if (g3 = g3 || f3.name || "download", typeof f3 != "string")
        navigator.msSaveOrOpenBlob(b2(f3, h2), g3);
      else if (d2(f3))
        c2(f3, g3, h2);
      else {
        var i2 = document.createElement("a");
        i2.href = f3, i2.target = "_blank", setTimeout(function() {
          e(i2);
        });
      }
    } : function(b3, d3, e2, g3) {
      if (g3 = g3 || open("", "_blank"), g3 && (g3.document.title = g3.document.body.innerText = "downloading..."), typeof b3 == "string")
        return c2(b3, d3, e2);
      var h2 = b3.type === "application/octet-stream", i2 = /constructor/i.test(f2.HTMLElement) || f2.safari, j2 = /CriOS\/[\d]+/.test(navigator.userAgent);
      if ((j2 || h2 && i2 || a2) && typeof FileReader != "undefined") {
        var k2 = new FileReader();
        k2.onloadend = function() {
          var a3 = k2.result;
          a3 = j2 ? a3 : a3.replace(/^data:[^;]*;/, "data:attachment/file;"), g3 ? g3.location.href = a3 : location = a3, g3 = null;
        }, k2.readAsDataURL(b3);
      } else {
        var l2 = f2.URL || f2.webkitURL, m2 = l2.createObjectURL(b3);
        g3 ? g3.location = m2 : location.href = m2, g3 = null, setTimeout(function() {
          l2.revokeObjectURL(m2);
        }, 4e4);
      }
    });
    f2.saveAs = g2.saveAs = g2, module.exports = g2;
  });
})(FileSaver_min);
var index_vue_vue_type_style_index_0_scoped_true_lang = /* @__PURE__ */ (() => ".upload-wrap[data-v-8c610a26] .ant-upload-select-picture-card i{font-size:32px;color:#999}.upload-wrap[data-v-8c610a26] .ant-upload-select-picture-card .ant-upload-text{margin-top:8px;color:#666}.upload-wrap[data-v-8c610a26] .ant-upload-list-picture-card .ant-upload-list-item,.upload-wrap[data-v-8c610a26] .ant-upload.ant-upload-select-picture-card,.upload-wrap[data-v-8c610a26] .ant-upload-list-picture-card-container{width:var(--26ed1042);height:var(--4252e1e5)}\n")();
var _export_sfc = (sfc, props) => {
  const target = sfc.__vccOpts || sfc;
  for (const [key, val] of props) {
    target[key] = val;
  }
  return target;
};
const _hoisted_1 = { class: "upload-wrap" };
const _hoisted_2 = /* @__PURE__ */ createTextVNode("\u4E0A\u4F20");
const _hoisted_3 = { style: { "padding": "20px 0" } };
const _hoisted_4 = ["src"];
const _hoisted_5 = ["src"];
const __default__ = defineComponent({
  name: "Upload",
  inheritAttrs: false
});
const _sfc_main = /* @__PURE__ */ defineComponent({
  ...__default__,
  props: {
    action: z.string.isRequired,
    accept: z.string.def(""),
    listType: z.oneOf(["picture-card", "text", "picture"]).def("picture-card"),
    multiple: z.bool.def(false),
    disabled: z.bool.def(false),
    maxSize: z.number.def(2),
    limit: z.number.def(1),
    type: z.oneOf(["file", "image", "video"]).def("image"),
    uploadData: z.object.def({}),
    headers: z.object.def({}),
    width: z.oneOfType([String, Number]).def(100),
    height: z.oneOfType([String, Number]).def(100),
    formatResponse: P().def((res) => res.data.url),
    value: z.arrayOf(A()).def([])
  },
  emits: ["update:value", "change"],
  setup(__props, { emit: emits }) {
    const props = __props;
    useCssVars((_ctx) => ({
      "26ed1042": unref(widthComputed),
      "4252e1e5": unref(heightComputed)
    }));
    const previewVisible = ref(false);
    const previewFileUrl = ref("");
    const fileList = ref([]);
    const handleCancel = () => {
      previewVisible.value = false;
    };
    async function handlePreview(file) {
      const fileUrl = file.url || props.formatResponse(file.response);
      if (props.type === "file") {
        window.open(fileUrl);
      } else {
        previewFileUrl.value = fileUrl;
        previewVisible.value = true;
      }
    }
    function handleDownload(file) {
      const fileUrl = file.url || file.originFileObj;
      const fileName = file.name;
      FileSaver_min.exports.saveAs(fileUrl, fileName);
    }
    const imageCount = ref(0);
    function beforeUpload(file, filelist) {
      imageCount.value = filelist.length;
      const isLimitNum = filelist.length + fileList.value.length <= props.limit;
      if (!isLimitNum) {
        message.warning(`\u4E0A\u4F20\u6587\u4EF6\u603B\u6570\u4E0D\u5F97\u8D85\u8FC7${props.limit}\u4E2A\uFF01`);
        fileList.value.splice(props.limit - filelist.length);
        return Upload$1.LIST_IGNORE;
      }
      const acceptList = props.accept.split(",").map((item) => item.trim()).filter((item) => !!item);
      for (let i2 = 0; i2 < filelist.length; i2++) {
        const file2 = filelist[i2];
        const extension = "." + file2.name.split(".").at(-1);
        if (acceptList.length && !acceptList.includes(extension)) {
          message.warning(`\u4E0A\u4F20\u6587\u4EF6\u7C7B\u578B\u4E3A${props.accept}`);
          return Upload$1.LIST_IGNORE;
        }
        if (file2.size > props.maxSize * 1024 * 1024) {
          message.warning(`\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F\u4E0D\u80FD\u8D85\u8FC7${props.maxSize}MB`);
          return Upload$1.LIST_IGNORE;
        }
      }
      return true;
    }
    function handleChange(info) {
      if (info.file.status === "done") {
        imageCount.value--;
        !imageCount.value && updateValue();
      } else if (info.file.status === "error") {
        message.error(`${info.file.name}\u4E0A\u4F20\u5931\u8D25\uFF01`);
        imageCount.value--;
        remove(info.file);
        !imageCount.value && updateValue();
      }
    }
    function remove(file) {
      const index2 = fileList.value.findIndex((item) => item.uid === file.uid);
      fileList.value.splice(index2, 1);
      updateValue();
      return false;
    }
    function updateValue() {
      const result = getFileUrlFromList(fileList.value);
      emits("update:value", result);
      emits("change", result);
    }
    function getFileUrlFromList(fileListScoped) {
      let urls = [];
      urls = fileListScoped.filter((file) => file.status === "done").map((file) => {
        return {
          name: file.name,
          url: file.url || props.formatResponse(file.response),
          type: file.type || ""
        };
      });
      console.log(urls);
      return urls;
    }
    const setFileList = function(value) {
      const formatFileList = [];
      value.forEach((item, i2) => {
        formatFileList.push({
          name: item.name || `file_${Math.random().toString(36).slice(2, 10)}`,
          status: "done",
          uid: "-" + (i2 + 1),
          url: item.url
        });
      });
      return formatFileList;
    };
    watch(() => props.value, (newValue) => {
      fileList.value = newValue ? setFileList(newValue) : [];
    }, { immediate: true, deep: true });
    const widthComputed = computed(() => {
      return props.width.toString().endsWith("px") ? props.width : props.width + "px";
    });
    const heightComputed = computed(() => {
      return props.height.toString().endsWith("px") ? props.height : props.height + "px";
    });
    return (_ctx, _cache) => {
      const _component_a_button = resolveComponent("a-button");
      const _component_a_upload = resolveComponent("a-upload");
      const _component_a_modal = resolveComponent("a-modal");
      return openBlock(), createElementBlock("div", _hoisted_1, [
        createVNode(_component_a_upload, mergeProps({
          "file-list": fileList.value,
          "onUpdate:file-list": _cache[0] || (_cache[0] = ($event) => fileList.value = $event),
          action: __props.action,
          "list-type": __props.listType,
          multiple: __props.multiple,
          accept: __props.accept,
          data: __props.uploadData,
          headers: __props.headers,
          disabled: __props.disabled,
          "max-count": __props.limit,
          onRemove: remove,
          onChange: handleChange,
          onPreview: handlePreview,
          onDownload: handleDownload,
          "before-upload": beforeUpload
        }, _ctx.$attrs), createSlots({ _: 2 }, [
          fileList.value.length < __props.limit ? {
            name: "default",
            fn: withCtx(() => [
              __props.type === "image" ? (openBlock(), createBlock(unref(PlusOutlined), { key: 0 })) : createCommentVNode("", true),
              __props.type === "video" ? (openBlock(), createBlock(unref(PlusOutlined), { key: 1 })) : createCommentVNode("", true),
              __props.type === "file" ? (openBlock(), createBlock(_component_a_button, { key: 2 }, {
                default: withCtx(() => [
                  _hoisted_2
                ]),
                _: 1
              })) : createCommentVNode("", true)
            ])
          } : void 0
        ]), 1040, ["file-list", "action", "list-type", "multiple", "accept", "data", "headers", "disabled", "max-count"]),
        createVNode(_component_a_modal, {
          visible: previewVisible.value,
          footer: null,
          onCancel: handleCancel
        }, {
          default: withCtx(() => [
            createElementVNode("div", _hoisted_3, [
              props.type === "image" ? (openBlock(), createElementBlock("img", {
                key: 0,
                alt: "example",
                style: { "width": "100%" },
                src: previewFileUrl.value
              }, null, 8, _hoisted_4)) : createCommentVNode("", true),
              props.type === "video" ? (openBlock(), createElementBlock("video", {
                key: 1,
                style: { "width": "100%" },
                src: previewFileUrl.value,
                controls: ""
              }, null, 8, _hoisted_5)) : createCommentVNode("", true)
            ])
          ]),
          _: 1
        }, 8, ["visible"])
      ]);
    };
  }
});
var UploadComponent = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-8c610a26"]]);
const AreaSelect = _sfc_main$1;
const Upload = UploadComponent;
var index = {
  install(Vue) {
    Vue.component("AreaSelect", _sfc_main$1);
    Vue.component("Upload", UploadComponent);
  }
};
export { AreaSelect, Upload, index as default };
